package com.ljp.consumer;

import com.common.model.User;
import com.common.service.UserService;
import com.ljp.RpcApplication;
import com.ljp.bootstrap.ConsumerBootstrap;
import com.ljp.config.RpcConfig;
import com.ljp.proxy.ServiceProxyFactory;
import com.ljp.registry.LocalRegistry;
import com.ljp.spi.SpiLoader;

/**
 * ClassName: EasyConsumerExample
 * Package: com.ljp.consumer
 * Description:
 *
 * @Author: ljp
 * @Create: 2025/6/3-下午 05:53
 * @Version: 1.0
 */
public class EasyConsumerExample {
    public static void main(String[] args) throws InstantiationException, IllegalAccessException {
        // 服务提供者初始化
        ConsumerBootstrap.init();

        // 获取代理,会获取配置类，不过是单例模式，不会重复初始化
        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
        User user = new User();
        user.setUsername("ljp");
        // 调用
        User newUser = userService.getUser(user);
        if (newUser != null) {
            System.out.println(newUser.getUsername());
        } else {
            System.out.println("user == null");
        }
    }
}
